<!--
 * @Author: wei_jt@ecidi.com
 * @Date: 2019-11-01 09:33:17
 * @LastEditors: wei_jt@ecidi.com
 * @LastEditTime: 2021-12-29 22:14:39
 * @Description: 主入口，布局
 -->
<template>
  <app-main id="fks-app" />
</template>

<script>
import { mapState, mapGetters } from 'vuex'
import * as types from '@/store/Getter/getterTypes'
import Mix from '@/mixins/module'
import { AppMain } from '@/layout/components'
import { updateStyle } from '@/utils/theme'
import { hideWatermark } from '@/utils/watermark'
import { clickEvent, scroll } from '@/utils/monitor'
export default {
  name: 'Global',
  components: { AppMain },
  mixins: [Mix],
  data() {
    return {}
  },

  computed: {
    ...mapGetters([
      types.THEME,
      types.WEBSITE_TEXT,
      types.WEBSITE_LOGO,
      types.STRIPE
    ])
  },
  watch: {
    //跳转到登录页取消水印
    $route: {
      immediate: true,
      handler: function (val) {
        if (val.name == 'login' || val.name == '404') hideWatermark()
      }
    },
    //logo变换
    websiteLogo: {
      immediate: true,
      handler: function (val) {
        document.getElementById('titleIcon').href = val
      }
    },
    //站名变换
    websiteText: {
      immediate: true,
      handler: function (val) {
        document.title = val
      }
    },
    //斑马纹
    stripe: {
      immediate: true,
      handler: function (val) {
        this.$fawkes.stripe = val
      }
    },
    theme: {
      immediate: true,
      handler: function (ntheme, otheme) {
        // 排除子应用干扰
        if (this.$InQianKun) {
          return false
        }
        document.documentElement.style.setProperty('--theme-color', ntheme)
        ntheme !== otheme && updateStyle(ntheme, otheme)
      }
    }
  },
  mounted() {
    // 排除子应用干扰
    if (this.$InQianKun) {
      return false
    }
    window.addEventListener('click', clickEvent, true)
    window.addEventListener('scroll', scroll, true)
  },
  methods: {}
}
</script>

